home *** CD-ROM | disk | FTP | other *** search
/ Learn Microsoft Visual Basic 6.0 Now / Learn Microsoft Visual Basic 6.0 Now (Microsoft Press)(X03-58607)(1998).ISO / media / chap08 / b08d005.cc2 < prev    next >
Text File  |  1998-06-07  |  3KB  |  68 lines

  1. 0, In this demonstration, I'll teach you 
  2. 3, how to add drag-and-drop support to your 
  3. 5, user interface. The special effect I'll 
  4. 7, create is a trash-can style burn barrel 
  5. 9, that you can use to discard unwanted 
  6. 11, objects on your form. The first step in 
  7. 14, drag-and-drop is setting the picture 
  8. 17, DragMode and DragIcon properties for the 
  9. 21, objects you plan to drag. In this program, 
  10. 25, these source objects are the CD icon, the 
  11. 28, gas pump icon, banana icon, and the match 
  12. 32, icon. Next, I'll continue to configure 
  13. 37, the target object for the drag-and-drop 
  14. 39, operation. In this case, the empty burn 
  15. 42, barrel. Since I want to add a flame 
  16. 45, effect when I drag in the match, I'll create 
  17. 48, a second icon that I can copy to the 
  18. 51, first empty burn barrel location. To hide 
  19. 54, the fire barrel until the right moment, 
  20. 57, I've set its Visible property to False. 
  21. 61, I'll verify that here in the Properties 
  22. 63, window. There's one last property 
  23. 65, setting I'd like to mention, and that's the 
  24. 68, Tag property for the match icon. The Tag 
  25. 71, property has been set to Fire. And in my 
  26. 74, event procedure, I'll check each source 
  27. 76, icon for the Tag property to see if fire 
  28. 79, has been put into the burn barrel. My 
  29. 82, point here is that I want to start the 
  30. 83, fire burning only when the match icon 
  31. 86, appears. Now, let's look at the program 
  32. 89, statements that complete the drag-and-drop 
  33. 91, operation. I'll double-click the target 
  34. 94, object and open the Code window. And I'll 
  35. 98, close the Properties window to get a 
  36. 100, better view. The first line uses the 
  37. 105, Source variable and the Visible property to 
  38. 108, hide the object that was dragged and 
  39. 110, dropped. This makes it look like the item 
  40. 112, was thrown into the burn barrel. The 
  41. 115, remaining lines check whether the object 
  42. 116, thrown away was the match icon. Remember, 
  43. 120, that I set the Tag property of the Image3 
  44. 123, object to Fire to identify it as the 
  45. 127, match that would light the burn barrel. The 
  46. 130, If...Then decision structure uses Tag 
  47. 132, Now to check whether the match is being 
  48. 134, thrown into the barrel. If it is, the 
  49. 139, decision structure lights the fire by 
  50. 141, copying the burn barrel icon over the empty 
  51. 144, barrel icon. Now that we've looked at the 
  52. 148, program code, let's run the program. 
  53. 155, When I drag the CD icon toward the burn 
  54. 156, barrel, I have a drag icon that appears, 
  55. 159, which in this case is the same as the 
  56. 161, original CD icon. When I drop it into the 
  57. 163, burn barrel, the CD icon disappears from 
  58. 166, the screen. The same happens when I drag 
  59. 168, the banana icon into the burn barrel 
  60. 171, and when I drag the gas pump icon into the 
  61. 173, burn barrel. This should really get the 
  62. 175, fire going. But when I drag the match 
  63. 178, icon and release it, boom! Not only does 
  64. 182, it remove the match icon, but it causes 
  65. 185, the Image1 swap, and lights the burn 
  66. 188, barrel. Well, that's it, drag and drop, 
  67. 191, step by step.
  68. 194, END